program Fjd;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
    f:TextFile;
    n, i, j, d: integer;
    mass: array of Integer;

begin
  Assign(f,'input.txt');
  Reset(f);
  read(f,n);
  SetLength(mass,n);
  for i:= 0 to n-1 do
   read(f,mass[i]);
  for i:= 0 to n-1 do
   for j:= 0 to n-2 do
    if(mass[j]>mass[j+1]) then
     begin
     d:=mass[j];
     mass[j]:=mass[j+1];
     mass[j+1]:=d;
     end;
      Close(f);
    write(mass[0]+mass[n-1]);

    readln;


     end.
